package com.eric.config;
import com.mybatisflex.core.FlexGlobalConfig;
import com.mybatisflex.core.audit.AuditManager;
import com.mybatisflex.core.audit.ConsoleMessageCollector;
import com.mybatisflex.core.audit.MessageCollector;
import com.mybatisflex.spring.boot.MyBatisFlexCustomizer;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MybatisFlexConfiguration implements MyBatisFlexCustomizer {
    @Override
    public void customize(FlexGlobalConfig flexGlobalConfig) {
//        乐观锁全局配置，对应数据库中version字段，这个如果用代码生成器生成version，可以不用这个
        FlexGlobalConfig.getDefaultConfig().setVersionColumn("version");
//       开启SQL审计功能，会在控制台输出
        AuditManager.setAuditEnable(true);
//        设置SQL审计收集器，然后控制台就会把相关内容打印出来得
        MessageCollector collector=new ConsoleMessageCollector();
        AuditManager.setMessageCollector(collector);
    }
}
